package day14_junit_reflect_annotation_proxy.com.itheima.d3_annotation;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Demo4_Annotation {
    public void test1(){
        System.out.println("---test1----");
    }

    @TestDlei
    public void test2(){
        System.out.println("---test2----");
    }
    public void test3(){
        System.out.println("---test3----");
    }
    @TestDlei(2)
    public void test4(){
        System.out.println("---test4----");
    }

    public static void main(String[] args) throws InvocationTargetException, IllegalAccessException {
        Demo4_Annotation t = new Demo4_Annotation();
        Class<Demo4_Annotation> c = Demo4_Annotation.class;
        Method[] methods = c.getDeclaredMethods();
        for (Method method : methods) {
            if (method.isAnnotationPresent(TestDlei.class)){
                TestDlei dlei = method.getDeclaredAnnotation(TestDlei.class);
                int value = dlei.value();
                for (int i = 0; i < value; i++) {
                    method.invoke(t);
                }
            }
        }
    }
}
